package com.school.common.tags;

public class PageBean {
	private int pageSize = 10;
	private int pageNo = 1;
	private int totalPageCount = 0;
	private int totalRecordCount = 0;
	private int offset = 0;

	public int getOffset() {
		int offset = (this.pageNo - 1) * this.pageSize;
		while (offset > 0 && offset >= this.totalRecordCount) {
			this.pageNo--;
			offset = (this.pageNo - 1) * this.pageSize;
		}
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getTotalPageCount() {
		if (totalRecordCount > 0 && pageSize > 0) {
			totalPageCount = totalRecordCount / pageSize;
			if (totalRecordCount % pageSize > 0) {
				totalPageCount++;
			}
		}
		return totalPageCount;
	}

	public int getTotalRecordCount() {
		return totalRecordCount;
	}

	public void setTotalRecordCount(int totalRecordCount) {
		this.totalRecordCount = totalRecordCount;
	}

}
